package com.david.rabbitmq.spirngboot.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author David
 * @version V1.0
 * @Package com.david.rabbitmq.spirngboot.config
 * @date 2021/7/18 9:53
 */
@Configuration
public class RabbitMqConfig {

    @Bean("directQueue")
    public Queue directQueue(){
        return new Queue("boot-q1");
    }
    @Bean("fanoutQueue")
    public Queue fanoutQueue(){
        return new Queue("boot-q2");
    }
    @Bean("topicQueue")
    public Queue topicQueue(){
        return new Queue("boot-q3");
    }

    @Bean("directExchange")
    public Exchange directExchange(){
        return new DirectExchange("boot.bx.direct",false,false,null);
    }
    @Bean("fanoutExchange")
    public Exchange fanoutExchange(){
        return new FanoutExchange("boot.bx.fanout",false,false,null);
    }
    @Bean("topicExchange")
    public Exchange topicExchange(){
        return new TopicExchange("boot.bx.topic",false,false,null);
    }

    @Bean("directBinding")
    public Binding directBinding(){
        return new Binding("boot-q1",Binding.DestinationType.QUEUE,
                "boot.bx.direct","boot.direct.key",null);
    }

    @Bean("fanoutBinding")
    public Binding fanoutBinding(){
        return new Binding("boot-q2",Binding.DestinationType.QUEUE,
                "boot.bx.fanout","",null);
    }

    @Bean
    public Binding topicBinding(){
        return new Binding("boot-q3",Binding.DestinationType.QUEUE,
                "boot.bx.topic","#.topic.*",null);
    }
}
